package 题目集.二分;

import java.util.Scanner;

public class ch07_数的范围 {
    static int[] arr;

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        arr=new int[n];
        int m=sc.nextInt();
        for (int i = 0; i < arr.length; i++) {
            arr[i]=sc.nextInt();
        }
        while (m-- > 0) {
            int x = sc.nextInt();
            int first = findFirst(x);
            int last=-1;
            if (first!=-1){
                last=findLast(x);
            }
            System.out.println(first+" "+last);
        }
    }

    public static int findFirst(int x) {
        int l = 0, r = arr.length - 1;
        while (l <= r) {
            int m = l + r >> 1;
            if (arr[m] >= x) {
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        if (r >= 0 && arr[r] == x) {
            return r;
        }
        if (l<arr.length&&arr[l]==x){
            return l;
        }
        return -1;
    }

    public static int findLast(int x) {
        int l = 0, r = arr.length - 1;
        while (l <= r) {
            int m = l + r >> 1;
            if (arr[m] > x) {
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        if (l<arr.length&&arr[l]==x){
            return l;
        }
        if (r >= 0 && arr[r] == x) {
            return r;
        }
        return -1;
    }
}
